<template>
  <div class="container">
    <div class="loading" v-if="loading">
      <van-loading type="spinner" size="24px" />
    </div>
  </div>
</template>

<script>
import { loginWithOpenId } from '../../utils/wx'

export default {
  data() {
    return {
      userKey: localStorage.getItem("userKey"),
      wxLoginClicked: localStorage.getItem('wxLoginClicked'),
      loading: true,
    }
  },
  mounted() {
    console.log('location href', location.href)
    
    // 通过主界面微信登录后，调用微信自动登录
    if(JSON.parse(this.wxLoginClicked) && !this.userKey){
      loginWithOpenId(this)
    }

  },
}
</script>

<style scoped>
.container{
  background-color: #000;
}
.loading{
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, .5);
}
</style>